package p2000;

import java.util.Scanner;

public class Main2018母牛的故事 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t;
        while ((t = scanner.nextInt()) != 0) {
            System.out.println(fn(t));
        }
    }

    private static int fn(int n) {
        if (n < 4) {
            return n;
        }

//        return fn(n - 4) + fn(n - 1) + 1;
        return fn(n - 3) + fn(n - 1);
    }

}
